<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt" %>

<fmt:setBundle basename="ApplicationResources" />

<table cellspacing="2" cellpadding="2" border="1" width="100%">

  <c:forEach var="courseList" items="${employeeCourseLists}">

    <tr>
      <th class="listSectionHeading" colspan="7">
        <c:url var="url" value="/protected/employeeHistory.do">
          <c:param name="employee_id" value="${courseList.employee.employeeId}" />
        </c:url>
        <a href="<c:out value="${url}"/>">
          <c:out value="${courseList.employee.name}"/>
        </a>
      </th>
    </tr>

    <c:set var="employeeCourses" value="${courseList.courses}"/>
    <c:choose>
      <c:when test="${empty employeeCourses}">
        <tr class="listRecord">
          <td><fmt:message key="caption.noCourses"/></td>
        </tr>
      </c:when>

      <c:otherwise>
        <tr class="listHeading">
          <th><fmt:message key="fieldLabel.reference"/></th>
          <th><fmt:message key="fieldLabel.name"/></th>
          <th><fmt:message key="fieldLabel.courseName"/></th>
          <th><fmt:message key="fieldLabel.startDate"/></th>
          <th><fmt:message key="fieldLabel.endDate"/></th>
          <th><fmt:message key="fieldLabel.fees"/></th>
          <th><fmt:message key="fieldLabel.status"/></th>
        </tr>

        <c:forEach var="employeeCourse" items="${employeeCourses}"> 

          <tr class="listRecord">
            <td>
              <c:url var="url" value="/protected/courseViewDetails.do">
                <c:param name="course_id" value="${employeeCourse.courseId}" />
              </c:url>
              <a href="<c:out value="${url}"/>">
                <c:out value="${employeeCourse.courseId}"/>
              </a>
            </td>
            <td>
              <c:out value="${employeeCourse.employeeId}"/>
            </td>
            <td>
              <c:out value="${employeeCourse.courseName}"/>
            </td>
            <td>
              <fmt:formatDate value="${employeeCourse.fromDate}"
                              pattern="${APPL_DATE_FORMAT}"/>
            </td>
            <td>
              <fmt:formatDate value="${employeeCourse.toDate}"
                              pattern="${APPL_DATE_FORMAT}"/>
            </td>

            <c:set var="fontcol" value="#0000FF"/>
            <c:if test="${employeeCourse.fees > 100}">
              <c:set var="fontcol" value="#FF0000"/>
            </c:if>

            <td>          
              <font color="<c:out value="${fontcol}" />">
                <c:out value="${employeeCourse.fees}"/>
              </font>
            </td>
            <td>
              <c:out value="${employeeCourse.status}"/>
            </td>
          </tr>

        </c:forEach>
      </c:otherwise>
    </c:choose>
  </c:forEach>
</table>

